<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method='html' encoding='UTF-8' doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent='yes'/>
	
	<!-- template to dinamically create main_app menu -->
	<xsl:template name="NavAppLoader">
		<xsl:param name="src"/>
		<xsl:variable name="page" select="page"/>
		<!-- get session ID variable -->
		<xsl:variable name="session"><xsl:value-of select="input/id"/></xsl:variable>
		<!--<xsl:copy-of select="replace($src/root/linkable/*,'3309','session')"/>-->
		<!-- navbar link list -->
		<ul id="main_app_nav_list">
			<li><a href="../index.html" accesskey="o">H<span class="underlined">o</span>me</a></li>
			<li><a href="../help.html" accesskey="h"><span class="underlined">H</span>elp</a></li>    
		</ul>
		<ul id="tools">
			<xsl:if test="page = 'browse'">
				<li id="feeds_tool" class="tools_here"><a title="Browse my feeds">Browse Feeds</a><span class="access_help"> (you are here)</span></li>
			</xsl:if>
			<xsl:if test="page != 'browse'">
				<li id="feeds_tool"><a title="Browse my feeds">
				<xsl:attribute name="href"><xsl:value-of select="concat('../cgi-bin/browse.pl?id=',$session)"/></xsl:attribute>
				Browse Feeds</a></li>
			</xsl:if>
			<xsl:if test="page = 'feedscribe'">
				<li id="add_tool" class="tools_here"><a title="Add new subscription">Add Feed</a><span class="access_help"> (you are here)</span></li>
			</xsl:if>
			<xsl:if test="page != 'feedscribe'">
				<li id="add_tool"><a title="Add new subscription">
				<xsl:attribute name="href"><xsl:value-of select="concat('../cgi-bin/addfeed.pl?id=',$session)"/></xsl:attribute>				
				Add Feed</a></li>
			</xsl:if>
			<xsl:if test="page = 'unfeedscribe'">
				<li id="delete_tool" class="tools_here"><a title="Remove subscription">Delete Feed</a><span class="access_help"> (you are here)</span></li>
			</xsl:if>
			<xsl:if test="page != 'unfeedscribe'">
				<li id="delete_tool"><a title="Remove subscription">
				<xsl:attribute name="href"><xsl:value-of select="concat('../cgi-bin/remfeed.pl?id=',$session)"/></xsl:attribute>
				Delete Feed</a></li>
			</xsl:if>
			<xsl:if test="page = 'manage'">
				<li id="manage_tool" class="tools_here"><a title="Manage feeds Groups">Manage Feeds</a><span class="access_help"> (you are here)</span></li>
			</xsl:if>
			<xsl:if test="page != 'manage'">
				<li id="manage_tool"><a title="Manage feeds Groups">
				<xsl:attribute name="href"><xsl:value-of select="concat('../cgi-bin/manage.pl?id=',$session)"/></xsl:attribute>				
				Manage Feeds</a></li>
			</xsl:if>
		</ul>
	</xsl:template>

	<!-- template to load extra data content -->
	<xsl:template name="GroupsLoader">
		<xsl:param name="src"/>
		<xsl:param name="groupname"/>
		<xsl:for-each select="$src/userfeed/group[@groupname != $groupname]">
			<option><xsl:value-of select="@groupname"/></option>
		</xsl:for-each>
	</xsl:template>
	
	<!-- template to load profile -->
	<xsl:template name="ProfileLoader">
		<xsl:param name="sid"/>
		<xsl:param name="page"/>
		<!-- /xml/.../.../x_username.xml -->
		<xsl:variable name="username" select="substring-before(substring-after(substring-after(substring-after(substring-after(substring-after(input/filedata,'/'),'/'),'/'),'/'),'_'),'.')"/>
			<div id="profile_wrapper">
			<img id="user_avatar" width="40px" height="50px" src="../images/icons/buddy.png" alt="User Avatar"/>
			<h3><xsl:value-of select="$username"/></h3>
			<span><a accesskey="o"><xsl:attribute name="href"><xsl:value-of select="concat('../cgi-bin/logout.pl?id=',$sid)"/></xsl:attribute>logout</a> | 
			<a accesskey="s">
				<xsl:if test="$page != 'profile'">
					<xsl:attribute name="href"><xsl:value-of select="concat('../cgi-bin/profile.pl?id=',$sid)"/></xsl:attribute>
				</xsl:if>
			settings</a></span>
		</div>

	</xsl:template>
	
</xsl:stylesheet>	
